package cmd

import (
	"github.com/spf13/cobra"
	global2 "longmen/server/config/global"
	"longmen/server/internal/services/nami/api/v5/sports/football"
	"longmen/server/internal/services/nami/config"
)

var testCli = &cobra.Command{
	Use:   "test",
	Short: "test cronjob server",
	Long:  "test cronjob server",
	Run: func(cmd *cobra.Command, args []string) {
		//mq := mqtt.BasketBallMQ{}
		////jsonStr := `[{"id":3560423,"score":[3560423,10,0,[19,19,15,24,0],[18,14,24,12,0]],"stats":[[1,1,5]],"tlive":[["1^10:00^2^0^0-0^卡罗琳·斯沃德斯 vs. 布里翁娜·琼斯 (凯拉·麦克布赖德 得到球)^53144,53098,53141^0^0^0^0,0","7^9:46^2^0^0-0^达尼埃尔·鲁滨逊 18英尺跳投不中^53142^1^0^0^14,14"]],"players":[[[53056,"德万娜·邦纳","","DeWanna Bonner","https://cdn.sportnanoapi.com/basketball/player/29c959c99cc27828c55c7c6ac5525728.jpg","24","33^4-11^0-3^4-4^1^9^10^2^0^0^0^2^15^12^1^0^0"]],[],"0^16-40^1-7^5-6^7^12^19^9^7^0^2^9^0^38","0^26-67^5-14^11-11^8^34^42^23^3^5^15^19^0^68"]}]`
		//bytes, _ := ioutil.ReadFile("./test.json")
		//
		//mq.Exec(bytes, 1)
		//
		//ball := basketball.BasketBall{}
		//ball.SyncOddsLive()

		f := football.Football{}
		f.SyncLineupWork()
		//crontab.AddFunc("@every 10s", services.NewAutoCreateMatchRoom().SyncRoom)
		//crontab.Start()
		//select {}
		//services.NewAutoCreateMatchRoom().SyncRoom()
		//services.NewAutoCreateMatchRoom().SyncRoom()
		//services.NewAutoCreateMatchRoom().SyncRoom()
	},
	PreRun: func(cmd *cobra.Command, args []string) {
		global2.Initialize(configFile)
		config.InitConfig()
		err := global2.InitElasticSearch()
		if err != nil {
			global2.Log.Fatalf("%s", err.Error())
		}
	},
	PostRun: func(cmd *cobra.Command, args []string) {

	},
}
